// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyThresholdOpAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyThresholdOpAttributes
//
// Purpose:
//   This class contains attributes for the threshold operator.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a ThresholdOpAttributes.
//
struct ThresholdOpAttributesObject
{
    PyObject_HEAD
    ThresholdOpAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewThresholdOpAttributes(int);
std::string
PyThresholdOpAttributes_ToString(const ThresholdOpAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    snprintf(tmpStr, 1000, "%soutputMeshType = %d\n", prefix, atts->GetOutputMeshType());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sboundsInputType = %d\n", prefix, atts->GetBoundsInputType());
    str += tmpStr;
    {   const stringVector &listedVarNames = atts->GetListedVarNames();
        snprintf(tmpStr, 1000, "%slistedVarNames = (", prefix);
        str += tmpStr;
        for(size_t i = 0; i < listedVarNames.size(); ++i)
        {
            snprintf(tmpStr, 1000, "\"%s\"", listedVarNames[i].c_str());
            str += tmpStr;
            if(i < listedVarNames.size() - 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const intVector &zonePortions = atts->GetZonePortions();
        snprintf(tmpStr, 1000, "%szonePortions = (", prefix);
        str += tmpStr;
        for(size_t i = 0; i < zonePortions.size(); ++i)
        {
            snprintf(tmpStr, 1000, "%d", zonePortions[i]);
            str += tmpStr;
            if(i < zonePortions.size() - 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const doubleVector &lowerBounds = atts->GetLowerBounds();
        snprintf(tmpStr, 1000, "%slowerBounds = (", prefix);
        str += tmpStr;
        for(size_t i = 0; i < lowerBounds.size(); ++i)
        {
            snprintf(tmpStr, 1000, "%g", lowerBounds[i]);
            str += tmpStr;
            if(i < lowerBounds.size() - 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    {   const doubleVector &upperBounds = atts->GetUpperBounds();
        snprintf(tmpStr, 1000, "%supperBounds = (", prefix);
        str += tmpStr;
        for(size_t i = 0; i < upperBounds.size(); ++i)
        {
            snprintf(tmpStr, 1000, "%g", upperBounds[i]);
            str += tmpStr;
            if(i < upperBounds.size() - 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    snprintf(tmpStr, 1000, "%sdefaultVarName = \"%s\"\n", prefix, atts->GetDefaultVarName().c_str());
    str += tmpStr;
    if(atts->GetDefaultVarIsScalar())
        snprintf(tmpStr, 1000, "%sdefaultVarIsScalar = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sdefaultVarIsScalar = 0\n", prefix);
    str += tmpStr;
    {   const stringVector &boundsRange = atts->GetBoundsRange();
        snprintf(tmpStr, 1000, "%sboundsRange = (", prefix);
        str += tmpStr;
        for(size_t i = 0; i < boundsRange.size(); ++i)
        {
            snprintf(tmpStr, 1000, "\"%s\"", boundsRange[i].c_str());
            str += tmpStr;
            if(i < boundsRange.size() - 1)
            {
                snprintf(tmpStr, 1000, ", ");
                str += tmpStr;
            }
        }
        snprintf(tmpStr, 1000, ")\n");
        str += tmpStr;
    }
    return str;
}

static PyObject *
ThresholdOpAttributes_Notify(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetOutputMeshType(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the outputMeshType in the object.
    obj->data->SetOutputMeshType(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetOutputMeshType(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetOutputMeshType()));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetBoundsInputType(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ int");
    }

    Py_XDECREF(packaged_args);

    // Set the boundsInputType in the object.
    obj->data->SetBoundsInputType(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetBoundsInputType(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetBoundsInputType()));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetListedVarNames(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    stringVector vec;

    if (PyUnicode_Check(args))
    {
        char const *val = PyUnicode_AsUTF8(args);
        std::string cval = std::string(val);
        if (val == 0 && PyErr_Occurred())
        {
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ string");
        }
        vec.resize(1);
        vec[0] = cval;
    }
    else if (PySequence_Check(args))
    {
        vec.resize(PySequence_Size(args));
        for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
        {
            PyObject *item = PySequence_GetItem(args, i);

            if (!PyUnicode_Check(item))
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_TypeError, "arg %d is not a unicode string", (int) i);
            }

            char const *val = PyUnicode_AsUTF8(item);
            std::string cval = std::string(val);

            if (val == 0 && PyErr_Occurred())
            {
                Py_DECREF(item);
                PyErr_Clear();
                return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ string", (int) i);
            }
            Py_DECREF(item);

            vec[i] = cval;
        }
    }
    else
        return PyErr_Format(PyExc_TypeError, "arg(s) must be one or more string(s)");

    obj->data->GetListedVarNames() = vec;
    // Mark the listedVarNames in the object as modified.
    obj->data->SelectListedVarNames();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetListedVarNames(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the listedVarNames.
    const stringVector &listedVarNames = obj->data->GetListedVarNames();
    PyObject *retval = PyTuple_New(listedVarNames.size());
    for(size_t i = 0; i < listedVarNames.size(); ++i)
        PyTuple_SET_ITEM(retval, i, PyString_FromString(listedVarNames[i].c_str()));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetZonePortions(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    intVector vec;

    if (PyNumber_Check(args))
    {
        long val = PyLong_AsLong(args);
        int cval = int(val);
        if (val == -1 && PyErr_Occurred())
        {
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "number not interpretable as C++ int");
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
            return PyErr_Format(PyExc_ValueError, "number not interpretable as C++ int");
        vec.resize(1);
        vec[0] = cval;
    }
    else if (PySequence_Check(args) && !PyUnicode_Check(args))
    {
        vec.resize(PySequence_Size(args));
        for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
        {
            PyObject *item = PySequence_GetItem(args, i);

            if (!PyNumber_Check(item))
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
            }

            long val = PyLong_AsLong(item);
            int cval = int(val);

            if (val == -1 && PyErr_Occurred())
            {
                Py_DECREF(item);
                PyErr_Clear();
                return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ int", (int) i);
            }
            if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ int", (int) i);
            }
            Py_DECREF(item);

            vec[i] = cval;
        }
    }
    else
        return PyErr_Format(PyExc_TypeError, "arg(s) must be one or more ints");

    obj->data->GetZonePortions() = vec;
    // Mark the zonePortions in the object as modified.
    obj->data->SelectZonePortions();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetZonePortions(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the zonePortions.
    const intVector &zonePortions = obj->data->GetZonePortions();
    PyObject *retval = PyTuple_New(zonePortions.size());
    for(size_t i = 0; i < zonePortions.size(); ++i)
        PyTuple_SET_ITEM(retval, i, PyInt_FromLong(long(zonePortions[i])));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetLowerBounds(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    doubleVector vec;

    if (PyNumber_Check(args))
    {
        double val = PyFloat_AsDouble(args);
        double cval = double(val);
        if (val == -1 && PyErr_Occurred())
        {
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "number not interpretable as C++ double");
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
            return PyErr_Format(PyExc_ValueError, "number not interpretable as C++ double");
        vec.resize(1);
        vec[0] = cval;
    }
    else if (PySequence_Check(args) && !PyUnicode_Check(args))
    {
        vec.resize(PySequence_Size(args));
        for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
        {
            PyObject *item = PySequence_GetItem(args, i);

            if (!PyNumber_Check(item))
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
            }

            double val = PyFloat_AsDouble(item);
            double cval = double(val);

            if (val == -1 && PyErr_Occurred())
            {
                Py_DECREF(item);
                PyErr_Clear();
                return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
            }
            if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
            }
            Py_DECREF(item);

            vec[i] = cval;
        }
    }
    else
        return PyErr_Format(PyExc_TypeError, "arg(s) must be one or more doubles");

    obj->data->GetLowerBounds() = vec;
    // Mark the lowerBounds in the object as modified.
    obj->data->SelectLowerBounds();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetLowerBounds(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the lowerBounds.
    const doubleVector &lowerBounds = obj->data->GetLowerBounds();
    PyObject *retval = PyTuple_New(lowerBounds.size());
    for(size_t i = 0; i < lowerBounds.size(); ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(lowerBounds[i]));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetUpperBounds(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    doubleVector vec;

    if (PyNumber_Check(args))
    {
        double val = PyFloat_AsDouble(args);
        double cval = double(val);
        if (val == -1 && PyErr_Occurred())
        {
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "number not interpretable as C++ double");
        }
        if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
            return PyErr_Format(PyExc_ValueError, "number not interpretable as C++ double");
        vec.resize(1);
        vec[0] = cval;
    }
    else if (PySequence_Check(args) && !PyUnicode_Check(args))
    {
        vec.resize(PySequence_Size(args));
        for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
        {
            PyObject *item = PySequence_GetItem(args, i);

            if (!PyNumber_Check(item))
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_TypeError, "arg %d is not a number type", (int) i);
            }

            double val = PyFloat_AsDouble(item);
            double cval = double(val);

            if (val == -1 && PyErr_Occurred())
            {
                Py_DECREF(item);
                PyErr_Clear();
                return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ double", (int) i);
            }
            if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_ValueError, "arg %d not interpretable as C++ double", (int) i);
            }
            Py_DECREF(item);

            vec[i] = cval;
        }
    }
    else
        return PyErr_Format(PyExc_TypeError, "arg(s) must be one or more doubles");

    obj->data->GetUpperBounds() = vec;
    // Mark the upperBounds in the object as modified.
    obj->data->SelectUpperBounds();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetUpperBounds(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the upperBounds.
    const doubleVector &upperBounds = obj->data->GetUpperBounds();
    PyObject *retval = PyTuple_New(upperBounds.size());
    for(size_t i = 0; i < upperBounds.size(); ++i)
        PyTuple_SET_ITEM(retval, i, PyFloat_FromDouble(upperBounds[i]));
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetDefaultVarName(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the defaultVarName in the object.
    obj->data->SetDefaultVarName(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetDefaultVarName(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    PyObject *retval = PyString_FromString(obj->data->GetDefaultVarName().c_str());
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetDefaultVarIsScalar(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the defaultVarIsScalar in the object.
    obj->data->SetDefaultVarIsScalar(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetDefaultVarIsScalar(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetDefaultVarIsScalar()?1L:0L);
    return retval;
}

/*static*/ PyObject *
ThresholdOpAttributes_SetBoundsRange(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;

    stringVector vec;

    if (PyUnicode_Check(args))
    {
        char const *val = PyUnicode_AsUTF8(args);
        std::string cval = std::string(val);
        if (val == 0 && PyErr_Occurred())
        {
            PyErr_Clear();
            return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ string");
        }
        vec.resize(1);
        vec[0] = cval;
    }
    else if (PySequence_Check(args))
    {
        vec.resize(PySequence_Size(args));
        for (Py_ssize_t i = 0; i < PySequence_Size(args); i++)
        {
            PyObject *item = PySequence_GetItem(args, i);

            if (!PyUnicode_Check(item))
            {
                Py_DECREF(item);
                return PyErr_Format(PyExc_TypeError, "arg %d is not a unicode string", (int) i);
            }

            char const *val = PyUnicode_AsUTF8(item);
            std::string cval = std::string(val);

            if (val == 0 && PyErr_Occurred())
            {
                Py_DECREF(item);
                PyErr_Clear();
                return PyErr_Format(PyExc_TypeError, "arg %d not interpretable as C++ string", (int) i);
            }
            Py_DECREF(item);

            vec[i] = cval;
        }
    }
    else
        return PyErr_Format(PyExc_TypeError, "arg(s) must be one or more string(s)");

    obj->data->GetBoundsRange() = vec;
    // Mark the boundsRange in the object as modified.
    obj->data->SelectBoundsRange();

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
ThresholdOpAttributes_GetBoundsRange(PyObject *self, PyObject *args)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)self;
    // Allocate a tuple the with enough entries to hold the boundsRange.
    const stringVector &boundsRange = obj->data->GetBoundsRange();
    PyObject *retval = PyTuple_New(boundsRange.size());
    for(size_t i = 0; i < boundsRange.size(); ++i)
        PyTuple_SET_ITEM(retval, i, PyString_FromString(boundsRange[i].c_str()));
    return retval;
}



PyMethodDef PyThresholdOpAttributes_methods[THRESHOLDOPATTRIBUTES_NMETH] = {
    {"Notify", ThresholdOpAttributes_Notify, METH_VARARGS},
    {"SetOutputMeshType", ThresholdOpAttributes_SetOutputMeshType, METH_VARARGS},
    {"GetOutputMeshType", ThresholdOpAttributes_GetOutputMeshType, METH_VARARGS},
    {"SetBoundsInputType", ThresholdOpAttributes_SetBoundsInputType, METH_VARARGS},
    {"GetBoundsInputType", ThresholdOpAttributes_GetBoundsInputType, METH_VARARGS},
    {"SetListedVarNames", ThresholdOpAttributes_SetListedVarNames, METH_VARARGS},
    {"GetListedVarNames", ThresholdOpAttributes_GetListedVarNames, METH_VARARGS},
    {"SetZonePortions", ThresholdOpAttributes_SetZonePortions, METH_VARARGS},
    {"GetZonePortions", ThresholdOpAttributes_GetZonePortions, METH_VARARGS},
    {"SetLowerBounds", ThresholdOpAttributes_SetLowerBounds, METH_VARARGS},
    {"GetLowerBounds", ThresholdOpAttributes_GetLowerBounds, METH_VARARGS},
    {"SetUpperBounds", ThresholdOpAttributes_SetUpperBounds, METH_VARARGS},
    {"GetUpperBounds", ThresholdOpAttributes_GetUpperBounds, METH_VARARGS},
    {"SetDefaultVarName", ThresholdOpAttributes_SetDefaultVarName, METH_VARARGS},
    {"GetDefaultVarName", ThresholdOpAttributes_GetDefaultVarName, METH_VARARGS},
    {"SetDefaultVarIsScalar", ThresholdOpAttributes_SetDefaultVarIsScalar, METH_VARARGS},
    {"GetDefaultVarIsScalar", ThresholdOpAttributes_GetDefaultVarIsScalar, METH_VARARGS},
    {"SetBoundsRange", ThresholdOpAttributes_SetBoundsRange, METH_VARARGS},
    {"GetBoundsRange", ThresholdOpAttributes_GetBoundsRange, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
ThresholdOpAttributes_dealloc(PyObject *v)
{
   ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *ThresholdOpAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyThresholdOpAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "outputMeshType") == 0)
        return ThresholdOpAttributes_GetOutputMeshType(self, NULL);
    if(strcmp(name, "boundsInputType") == 0)
        return ThresholdOpAttributes_GetBoundsInputType(self, NULL);
    if(strcmp(name, "listedVarNames") == 0)
        return ThresholdOpAttributes_GetListedVarNames(self, NULL);
    if(strcmp(name, "zonePortions") == 0)
        return ThresholdOpAttributes_GetZonePortions(self, NULL);
    if(strcmp(name, "lowerBounds") == 0)
        return ThresholdOpAttributes_GetLowerBounds(self, NULL);
    if(strcmp(name, "upperBounds") == 0)
        return ThresholdOpAttributes_GetUpperBounds(self, NULL);
    if(strcmp(name, "defaultVarName") == 0)
        return ThresholdOpAttributes_GetDefaultVarName(self, NULL);
    if(strcmp(name, "defaultVarIsScalar") == 0)
        return ThresholdOpAttributes_GetDefaultVarIsScalar(self, NULL);
    if(strcmp(name, "boundsRange") == 0)
        return ThresholdOpAttributes_GetBoundsRange(self, NULL);


    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyThresholdOpAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyThresholdOpAttributes_methods[i].ml_name),
                PyString_FromString(PyThresholdOpAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyThresholdOpAttributes_methods, self, name);
}

int
PyThresholdOpAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "outputMeshType") == 0)
        obj = ThresholdOpAttributes_SetOutputMeshType(self, args);
    else if(strcmp(name, "boundsInputType") == 0)
        obj = ThresholdOpAttributes_SetBoundsInputType(self, args);
    else if(strcmp(name, "listedVarNames") == 0)
        obj = ThresholdOpAttributes_SetListedVarNames(self, args);
    else if(strcmp(name, "zonePortions") == 0)
        obj = ThresholdOpAttributes_SetZonePortions(self, args);
    else if(strcmp(name, "lowerBounds") == 0)
        obj = ThresholdOpAttributes_SetLowerBounds(self, args);
    else if(strcmp(name, "upperBounds") == 0)
        obj = ThresholdOpAttributes_SetUpperBounds(self, args);
    else if(strcmp(name, "defaultVarName") == 0)
        obj = ThresholdOpAttributes_SetDefaultVarName(self, args);
    else if(strcmp(name, "defaultVarIsScalar") == 0)
        obj = ThresholdOpAttributes_SetDefaultVarIsScalar(self, args);
    else if(strcmp(name, "boundsRange") == 0)
        obj = ThresholdOpAttributes_SetBoundsRange(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
ThresholdOpAttributes_print(PyObject *v, FILE *fp, int flags)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)v;
    fprintf(fp, "%s", PyThresholdOpAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
ThresholdOpAttributes_str(PyObject *v)
{
    ThresholdOpAttributesObject *obj = (ThresholdOpAttributesObject *)v;
    return PyString_FromString(PyThresholdOpAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *ThresholdOpAttributes_Purpose = "This class contains attributes for the threshold operator.";
#else
static char *ThresholdOpAttributes_Purpose = "This class contains attributes for the threshold operator.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(ThresholdOpAttributesType,         \
                  "ThresholdOpAttributes",           \
                  ThresholdOpAttributesObject,       \
                  ThresholdOpAttributes_dealloc,     \
                  ThresholdOpAttributes_print,       \
                  PyThresholdOpAttributes_getattr,   \
                  PyThresholdOpAttributes_setattr,   \
                  ThresholdOpAttributes_str,         \
                  ThresholdOpAttributes_Purpose,     \
                  ThresholdOpAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
ThresholdOpAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &ThresholdOpAttributesType
         || Py_TYPE(other) != &ThresholdOpAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    ThresholdOpAttributes *a = ((ThresholdOpAttributesObject *)self)->data;
    ThresholdOpAttributes *b = ((ThresholdOpAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static ThresholdOpAttributes *defaultAtts = 0;
static ThresholdOpAttributes *currentAtts = 0;

static PyObject *
NewThresholdOpAttributes(int useCurrent)
{
    ThresholdOpAttributesObject *newObject;
    newObject = PyObject_NEW(ThresholdOpAttributesObject, &ThresholdOpAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new ThresholdOpAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new ThresholdOpAttributes(*defaultAtts);
    else
        newObject->data = new ThresholdOpAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapThresholdOpAttributes(const ThresholdOpAttributes *attr)
{
    ThresholdOpAttributesObject *newObject;
    newObject = PyObject_NEW(ThresholdOpAttributesObject, &ThresholdOpAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (ThresholdOpAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
ThresholdOpAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewThresholdOpAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef ThresholdOpAttributesMethods[] = {
    {"ThresholdOpAttributes", ThresholdOpAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *ThresholdOpAttributesObserver = 0;

std::string
PyThresholdOpAttributes_GetLogString()
{
    std::string s("ThresholdOpAtts = ThresholdOpAttributes()\n");
    if(currentAtts != 0)
        s += PyThresholdOpAttributes_ToString(currentAtts, "ThresholdOpAtts.", true);
    return s;
}

static void
PyThresholdOpAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("ThresholdOpAtts = ThresholdOpAttributes()\n");
        s += PyThresholdOpAttributes_ToString(currentAtts, "ThresholdOpAtts.", true);
        cb(s);
    }
}

void
PyThresholdOpAttributes_StartUp(ThresholdOpAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyThresholdOpAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(ThresholdOpAttributesObserver == 0)
    {
        ThresholdOpAttributesObserver = new ObserverToCallback(subj,
            PyThresholdOpAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyThresholdOpAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete ThresholdOpAttributesObserver;
    ThresholdOpAttributesObserver = 0;
}

PyMethodDef *
PyThresholdOpAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return ThresholdOpAttributesMethods;
}

bool
PyThresholdOpAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &ThresholdOpAttributesType);
}

ThresholdOpAttributes *
PyThresholdOpAttributes_FromPyObject(PyObject *obj)
{
    ThresholdOpAttributesObject *obj2 = (ThresholdOpAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyThresholdOpAttributes_New()
{
    return NewThresholdOpAttributes(0);
}

PyObject *
PyThresholdOpAttributes_Wrap(const ThresholdOpAttributes *attr)
{
    return WrapThresholdOpAttributes(attr);
}

void
PyThresholdOpAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    ThresholdOpAttributesObject *obj2 = (ThresholdOpAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyThresholdOpAttributes_SetDefaults(const ThresholdOpAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new ThresholdOpAttributes(*atts);
}

